package com.sky.business.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.business.sys.domain.ContainerConfig;
import com.sky.business.sys.mapper.ContainerConfigMapper;
import com.sky.business.sys.service.ContainerConfigService;
import com.sky.common.enums.Arch;
import com.sky.common.enums.TaskType;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ContainerConfigServiceImpl extends ServiceImpl<ContainerConfigMapper, ContainerConfig> implements ContainerConfigService{

    @Override
    public List<ContainerConfig> findByTaskTypeAndArch(TaskType taskType, Arch arch) {
        LambdaQueryWrapper<ContainerConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ContainerConfig::getIsDel,false);
        queryWrapper.eq(ContainerConfig::getTaskType,taskType);
        queryWrapper.eq(ContainerConfig::getImageArch,arch);
        queryWrapper.orderByDesc(ContainerConfig::getVersion);
        return getBaseMapper().selectList(queryWrapper);
    }

    @Override
    public List<ContainerConfig> findByTaskType(TaskType taskType) {
        LambdaQueryWrapper<ContainerConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ContainerConfig::getIsDel,false);
        queryWrapper.eq(ContainerConfig::getTaskType,taskType);
        queryWrapper.orderByDesc(ContainerConfig::getVersion);
        return getBaseMapper().selectList(queryWrapper);
    }

}
